package com.exercises;


import java.util.Deque;
import java.util.LinkedList;

class Exercise1106 {
    public static void main(String[] args) {
        System.out.println(clumsy(10));
    }


    public static int clumsy(int N) {
        Deque<Integer> stack = new LinkedList<>();
        stack.push(N);

        int index = 0;
        for (int i = N - 1; i > 0; i--) {
            switch (index % 4) {
                case 0:
                    stack.push(stack.pop() * i);
                    break;
                case 1:
                    stack.push((int) Math.floor(stack.pop() / i));
                    break;
                case 2:
                    stack.push(i);
                    break;
                case 3:
                    stack.push(-i);
                    break;

            }
            index++;
        }
        int result = 0;
        while (stack.size() > 0) {
            result = result + stack.pop();
        }

        return result;
    }


}

